package com.mvp.shq.washer.ui.shop.order.refund;


import com.mvp.shq.washer.entity.result.BaseResult;
import com.mvp.shq.washer.http.BaseObserver;
import com.mvp.shq.washer.utils.SpUtil;
import com.mvp.shq.washer.utils.T;

import java.util.Map;

import okhttp3.RequestBody;

/**
 * Created by westing on 2017/10/12.
 */
public class Presenter extends RefundConstract.Presenter {
    @Override
    public void onStart() {

    }

    @Override
    void submitRefund(String orderId, String receiveStatus, String refundReason, Map<String, RequestBody> maps) {
        String token = SpUtil.getToken();
        String userId = SpUtil.getUser().getId();
        model.submitRefund(token,userId,orderId,receiveStatus,refundReason,maps)
                .compose(getActivityLifecycleProvider().bindToLifecycle())
                .subscribe(new BaseObserver<String>(view) {
                    @Override
                    protected void onSuccees(BaseResult<String> t) throws Exception {
                        if (t.isError()){
                            T.show(t.getMsg());
                        }else {
                            view.submitS();
                        }
                    }

                    @Override
                    protected void onFailure(Throwable e, boolean isNetWorkError) throws Exception {
                        T.show(e.getMessage());
                        e.printStackTrace();
                    }
                });
    }
}
